package com.alibaba.alink.params.finance;

import org.apache.flink.ml.api.misc.param.ParamInfo;
import org.apache.flink.ml.api.misc.param.ParamInfoFactory;
import org.apache.flink.ml.api.misc.param.WithParams;

import com.alibaba.alink.common.annotation.DescCn;
import com.alibaba.alink.common.annotation.NameCn;
import com.alibaba.alink.params.ParamUtil;

import java.io.Serializable;

public interface HasBinningMethod<T> extends WithParams <T> {

	@NameCn("连续特征分箱方法")
	@DescCn("连续特征分箱方法")
	ParamInfo <BinningMethod> BINNIG_METHOD = ParamInfoFactory
		.createParamInfo("binningMethod", BinningMethod.class)
		.setDescription("Binning Method")
		.setHasDefaultValue(BinningMethod.QUANTILE)
		.build();

	default BinningMethod getBinningMethod() {
		return get(BINNIG_METHOD);
	}

	default T setBinningMethod(BinningMethod value) {
		return set(BINNIG_METHOD, value);
	}

	default T setBinningMethod(String value) {
		return set(BINNIG_METHOD, ParamUtil.searchEnum(BINNIG_METHOD, value));
	}

	/**
	 * DivideType for Numeric FeatureBins.
	 */
	enum BinningMethod implements Serializable {
		/**
		 * Numeric featureBins, it's generated by QuantileDiscretizerTrainBatchOp.
		 * All bins in each feature have the same number of points.
		 */
		QUANTILE,

		/**
		 * Numeric featureBins, it's generated by EqualWidthDiscretizerTrainBatchOp.
		 * The width of all bins are equal.
		 */
		BUCKET;
	}

}
